/*
 * @Author: 鱿鱼溪学院
 * @Date: 2025-02-05 21:11:38
 * @LastEditTime: 2025-07-28 00:57:31
 * @LastEditors: 鱿鱼溪学院
 * @Description:
 * @FilePath: \yyx-web\vite.config.ts
 * Copyright 鱿鱼溪学院 by edu v1.0
 * 天道酬勤
 */
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueDevTools()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    proxy: {
      '/api': {
        // target: "http://testapi.xuexiluxian.cn",
        target: 'http://testapi.xuexiluxian.cn',
        changeOrigin: true
      },
      '/aa': {
        //获取数据的服务器地址设置、
        //target: 'http://192.168.2.37:3000',
        // target: 'http://192.168.2.37:3000',
        //target: 'http://localhost:8000',
        target: 'http://127.0.0.1:3000',
        //需要代理跨域
        changeOrigin: true,
        //路径重写
        rewrite: (path: any) => path.replace(/^\/aa/, '')
      }
    }
  }
})
